using System.Collections;
using System.Collections.Generic;
using XFGameFramework;
using UnityEngine;
using XFABManager;
using XFGameFramework.ScriptableObjectSystem;
using PixelCrushers.DialogueSystem;
public enum Location
{
    城市 = 1,
    郊外,
    山岭
}

public class DSEvent : MonoBehaviour
{
    private Module module;
    private ScriptableObjectConfigs location;
    private ScriptableObjectConfigs food;
    private Location currentLocation = Location.城市;
    private void Start()
    {
        module = ModuleManager.GetModule("MainModule");

        //查询到对应配表
        location = ScriptableObjectManager.GetConfig("LocationConfig");
        food = ScriptableObjectManager.GetConfig("FoodConfig");
    }

    #region 方法
    private LocationConfigData GetLocationData(int id)
    {
        return location.GetScriptableObjectData(id) as LocationConfigData;
    }
    private FoodConfigData GetFoodData(int id)
    {
        return food.GetScriptableObjectData(id) as FoodConfigData;
    }

    #endregion
    #region 地区
    public void 城市()
    {
        print("城市");
        currentLocation = Location.城市;
        // 强制立即停止当前对话
        DialogueManager.StopConversation();
        DialogueManager.StartConversation("选择活动");

    }

    public void 郊外()
    {
        print("郊外");
    }
    public void 山岭()
    {
        print("山岭");
    }
    #endregion
    #region 寻找食物
    public void 寻找食物()
    {
        print("寻找食物");
        //加载地区数据
        LocationConfigData locationData = GetLocationData((int)currentLocation);
        //是否遭遇敌人
        int result = Utility.GetRandomEvent(locationData.enemyEncounterLikelihood);
        switch (result)
        {
            case 1:
                print("遭遇敌人1");
                break;
            case 2:
                print("遭遇敌人2");
                break;
            case 3:
                print("遭遇敌人3");
                break;
            case -1:
                print("无事发生，没有遭遇敌人");
                break;
        }
        //TODO 得到什么食物
        int foodId = Utility.GetRandomId(locationData.foodEncounterLikelihood);
        FoodConfigData foodData = GetFoodData(foodId);
        //TODO 是否竞争
        switch (foodData.level)
        {
            case "普通":

                break;
            case "稀有":

                break;
            case "罕见":
                break;
        }
        //TODO 输出结果 

        //TODO 解锁高级行动
    }
    #endregion
    #region 游荡
    public void 游荡()
    {
        print("游荡");
        //TODO 发现地点

        //
    }
    #endregion
    #region 娱乐
    public void 娱乐()
    {
        print("娱乐");
    }
    #endregion
    #region 思考
    public void 思考()
    {
        print("思考");

    }
    #endregion
    #region DialogueSystem Related
    // 清除文本并开始新对话
    public void 开始新对话()
    {

    }
    public void ResetDialogue(string newConversation)
    {
        // 获取对话UI组件
        var dialogueUI = DialogueManager.dialogueUI as UnityUIDialogueUI;

        // 清除当前文本
        if (dialogueUI != null)
        {
            dialogueUI.OnContinue(); // 跳过当前显示动画

            dialogueUI.ShowSubtitle(null); // 清除UI内容
        }

        // 开始新对话
        DialogueManager.StartConversation(newConversation);
    }
    #endregion
}
